package restaurant.iterators;

import static org.junit.Assert.*;

import java.util.NoSuchElementException;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import restaurant.Menu;
import restaurant.MenuItem;

/**
 * Test case for the ByVegetarianIterator class. Tests to ensure the
 * {@code hasNext} and {@code next} methods work correctly.
 * 
 * @author Odessa
 */
public class ByVegetarianIteratorTest
{
	Menu menu;
	Iterator it;



	/**
	 * Sets up the test fixture.
	 * 
	 * @throws Exception the exception
	 */
	@Before
	public void setUp() throws Exception
	{
		menu = new Menu();
	}



	/**
	 * Tears down the test fixture.
	 * 
	 * @throws Exception the exception
	 */
	@After
	public void tearDown() throws Exception
	{
		menu = null;
		it = null;
	}



	/**
	 * Test method for {@link restaurant.iterators.ByVegetarianIterator#hasNext()}. Tests
	 * hasNext() if there are more vegetarian items on the menu.
	 */
	@Test
	public void testHasNext_Yes()
	{
		menu.createItem("Grilled Dijon Chicken & Portobellos",
				"Marinated chicken breast grilled and topped with roasted red "
						+ "peppers, onions, portobello mushrooms, Dijon sauce "
						+ "and aged white cheddar. Served with steamed herb "
						+ "potatoes and seasonal vegetables ", 11.99, 20,
				"Entree", true);
		it = menu.getByVegetarianIterator();

		assertTrue(it.hasNext());
	}



	/**
	 * Test method for {@link restaurant.iterators.ByPrepTimeIterator#hasNext()}. Tests
	 * hasNext() if there are no more vegetarian items on the menu.
	 */
	@Test
	public void testHasNext_No()
	{
		it = menu.getByVegetarianIterator();
		assertFalse(it.hasNext());
	}



	/**
	 * Test method for {@link restaurant.iterators.ByVegetarianIterator#next()}. Tests
	 * next() if there are more vegetarian items on the menu.
	 */
	@Test(expected = NoSuchElementException.class)
	public void testNext_MoreItems()
	{
		menu.createItem("Grilled Dijon Chicken & Portobellos",
				"Marinated chicken breast grilled and topped with roasted red "
						+ "peppers, onions, portobello mushrooms, Dijon sauce "
						+ "and aged white cheddar. Served with steamed herb "
						+ "potatoes and seasonal vegetables ", 11.99, 20,
				"Entree", true);
		it = menu.getByVegetarianIterator();

		MenuItem m = new MenuItem(1, "Grilled Dijon Chicken & Portobellos",
				"Marinated chicken breast grilled and topped with roasted red "
						+ "peppers, onions, portobello mushrooms, Dijon sauce "
						+ "and aged white cheddar. Served with steamed herb "
						+ "potatoes and seasonal vegetables ", 11.99, 20,
				"Entree", true);
		assertEquals(m, it.next());
	}



	/**
	 * Test method for {@link restaurant.iterators.ByPrepTimeIterator#next()}. Tests
	 * next() if there are no more vegetarian items on the menu.
	 */
	@Test(expected = NoSuchElementException.class)
	public void testNext_NoMoreItems()
	{
		it = menu.getByVegetarianIterator();
		it.next();
	}

}
